package com.csun.cmny.provider.service.impl;

import com.csun.cmny.base.dto.LoginAuthDto;
import com.csun.cmny.core.support.BaseService;
import com.csun.cmny.provider.dao.OmcOldManSupplementMapper;
import com.csun.cmny.provider.model.domain.OmcOldManSupplement;
import com.csun.cmny.provider.model.dto.OmcOldManSupplementDto;
import com.csun.cmny.provider.service.OmcOldManSupplementService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author chenzheng
 * @description:
 * @date 2019/7/28 14:29
 */
@Slf4j
@Service
@Transactional
public class OmcOldManSupplementServiceImpl  extends BaseService<OmcOldManSupplement> implements OmcOldManSupplementService {

    @Resource
    private OmcOldManSupplementMapper oldManSupplementMapper;

    /**
     * 保存或者跟新老人额外信息
     * @param oldManSupplement
     * @return
     */
    @Override
    public int saveOldManSupplement(OmcOldManSupplement oldManSupplement, LoginAuthDto loginAuthDto) {
        oldManSupplement.setUpdateInfo(loginAuthDto);
        if(oldManSupplement.isNew()){//新增
            oldManSupplementMapper.insertSelective(oldManSupplement);
        }else{//跟新
            oldManSupplementMapper.updateByPrimaryKeySelective(oldManSupplement);
        }
        return 0;
    }

    /**
     * query oldman special case by oldman id
     *
     * @param oldmanId the oldman id
     *
     * @return the oldman special case
     */
    @Override
    public String queryOldmanSpecialCaseByOldmanId(Integer oldmanId) {

        return oldManSupplementMapper.queryOldmanSpecialCaseByOldmanId(oldmanId);
    }

    @Override
    public int updateById(OmcOldManSupplement omcOldManSupplement) {
        return oldManSupplementMapper.updateByPrimaryKey(omcOldManSupplement);
    }


    /*
     * 修改大健康数据
     * */
    @Override
    public Integer updateHealth(OmcOldManSupplement omcOldManSupplement) {
        return oldManSupplementMapper.updateHealth(omcOldManSupplement);
    }
}
